/**
 * addClass adds a class to an element
 *
 * @param element is the element
 * @param class is the class
 *
 * @return true or false
*/
function addClass(element, class_name) {
	
	// Get current classes
	try {
		
		// Split classes
		var classes = element.className.split(" ");
		
		// If no classes exist, just put this one in
		if (classes.length == 0) {
			
			// Add, OK
			element.className = class_name;
			return true;
			
		} else {
			
			// If class not already in the list
			if (findInArray(classes, class_name) == -1) {
				
				// Add new class
				classes.push(class_name);
				
				// Assign class
				element.className = classes.join(" ");
			}
			
			// OK
			return true;
		}
	} catch (error) {
		return false;
	}
}

function removeClass(element, class_name) {
	
	// Get current classes
	try {
		
		// Split classes
		var classes = element.className.split(" ");
		
		// If found
		var index = findInArray(classes, class_name);
		if (index != -1) {
			classes.splice(index, 1);
		}
		
		// Recompile and set
		element.className = classes.join(" ");
		return true;

	} catch (error) {
		return false;
	}
}

function hasClass(element, class_name) {
	
	// Get current classes
	try {
		
		// Split classes
		var classes = element.className.split(" ");
		
		// Return if found
		return findInArray(classes, class_name) != -1;

	} catch (error) {
		return false;
	}
	
}

